	CHARACTER*1 TYPE,ANS
	CHARACTER*3 MON(12),MS,ME,ENDMONTH(100)
	CHARACTER*2 YEAR
	CHARACTER*4 CBTT(100),FORECAST,CBTS
	CHARACTER*19 THE_REST
	CHARACTER*23 TITLE(100),WRITE(100),TIT(100)
C
	INTEGER WR
C
	DIMENSION MYS(100),MYE(100),MN(12)
C
	DATA MON/'OCT','NOV','DEC','JAN','FEB','MAR','APR',
	1        'MAY','JUN','JUL','AUG','SEP'/
	DATA MN/1,2,3,4,5,6,7,8,9,10,11,12/
C
	I=1
101	READ(1,6,END=102)CBTT(I),ENDMONTH(I),MYS(I),MYE(I),TIT(I)
6	FORMAT(21X,A,5X,A,8X,I4,1X,I4,14X,A)
	I=I+1
	GO TO 101
C
102	LAST=I-1
C
	WRITE(6,15)
15 	FORMAT(' BE READY TO HIT THE HOLD SCREEN KEY ENTER CR>',$)
	READ(5,8)ANS
	WRITE(6,11)(TIT(J),CBTT(J),J=1,LAST)
11	FORMAT(' ENTER A FORECAST POINT CBTT ID.    "CBTT CODE" '/,
	1      ' OR FOR ALL FORECAST POINTS ENTER   "ALL"    '/,
	1      ' OR TO SELECT FORECASTS ENTER A     "S"'//,
	1      ' FORECAST                 CBTT CODE'/,
	1        <LAST>(1X,A,2X,A/)//,
	1      ' ENTER A CBTT CODE OR "ALL" OR "S" >',$)
C
	FORECAST='    '
	READ(5,8)FORECAST
C
C
	IF(FORECAST(1:1) .EQ. 'S')THEN
		WRITE(6,13)
13		FORMAT(' ENTER A "Y" BY EACH CBTT CODE LISTED')
		NTIT=0
C
		DO 212 K=1,LAST
C
		WRITE(6,12)TIT(K),CBTT(K)
12		FORMAT(1X,A,',',A,' >',$)
		READ(5,8)ANS
		IF(ANS .EQ. 'Y')THEN
			NTIT=NTIT+1
			TITLE(NTIT)=TIT(K)
			END IF
C
212		CONTINUE  
C
	ELSE IF(FORECAST(1:3) .EQ. 'ALL')THEN
		DO 205 K=1,LAST
		TITLE(K)=TIT(K)
205		CONTINUE
	ELSE IF(FORECAST .NE. 'ALL ' .AND. FORECAST .NE. 'S   ')THEN
C
		DO 206 K=1,LAST
		IF(FORECAST .EQ. CBTT(K))THEN
			TITLE(1)=TIT(K)
			CBTS=CBTT(K)
			END IF
206		CONTINUE
C
	END IF
C
C
105	WRITE(6,10)
10	FORMAT(' IF A FORECAST GENERATION IS WANTED ENTER A "G"'/,
	1' IF FINAL VARIABLE CHECKING IS WANTED ENTER A "V"'/,
	1' ENTER A "G" OR AN "V" >',$)
	READ(5,8)TYPE
C
C
	IF(TYPE .EQ. 'V')THEN 	 
		WRITE(6,1)
1		FORMAT(' ENTER STARTING YEAR >',$)
		READ(5,2)ISY
2		FORMAT(I4)
		WRITE(6,3)
3		FORMAT(' ENTER ENDING YEAR >',$)
		READ(5,2)IEY
C
		WRITE(6,4)
4		FORMAT(' ENTER FORECAST DATE e.g. "JUN,AUG" >',$)
		READ(5,5)MS,ME
5		FORMAT(A,1X,A)
	ELSE IF(TYPE .EQ. 'G')THEN
		MS='JAN'
		ME='JUL'
C
		DO 207 K=1,LAST
		IF(TITLE(1).EQ.TIT(K))THEN
			ISY=MYS(K)
			IEY=MYE(K)
			GO TO 211
			END IF
207		CONTINUE
211		CONTINUE
C
	END IF
	IF(TYPE .NE. 'G' .AND. TYPE .NE. 'V')GO TO 105
C
	THE_REST='       150.00 50.00'
C
	DO 100 I=1,12
C
	IF(MS .EQ. MON(I))IMS=MN(I)
	IF(ME .EQ. MON(I))IME=MN(I)
C
100	CONTINUE
C
C
C
C
	IF(TYPE .EQ. 'V')THEN
C
		DO 200 IY=ISY,IEY
C
		IYEAR=IY-1900
		ENCODE(2,7,YEAR)IYEAR
7		FORMAT(I2)
C
		IMM=IMS
C
		DO 204 K=1,LAST
C
		IF(IY.GE.MYS(K))THEN
			DO 213 L=1,12
			IF(ENDMONTH(K) .EQ. MON(L))IMT=MN(L)
213			CONTINUE
			END IF
		IF(IMM.GT.IMT)GO TO 104
		IMM=IMT	
104		IF(IMM.EQ.IME)GO TO 103
C
204		CONTINUE
C
103		DO 201 N=IMS,IMM
C
		OPEN(UNIT=2,FILE='FOREQ_'//MON(N)//'.'//YEAR,
	1	CARRIAGECONTROL='LIST',STATUS='UNKNOWN')
C
8		FORMAT(A)
		IF(MON(N) .EQ. 'JUN')WRITE(2,8)'JULY 1'
		IF(MON(N) .EQ. 'JUL')WRITE(2,8)'AUGUST 1'
		IF(MON(N) .EQ. 'AUG')WRITE(2,8)'SEPTEMBER 1'
		WR=0
C
		DO 202 K=1,LAST
C
		IF(IY .LT. MYS(K))GO TO 202
		IF(IY .GT. MYE(K))GO TO 202
		IF(ENDMONTH(K) .NE. MON(N))GO TO 202
		IF(WR .EQ. 0)THEN
			WR=1
			WRITE(2,9)TITLE(K),THE_REST
9			FORMAT(2A)
			WRITE(WR)=TITLE(K)
			GO TO 202
			ENDIF
C
		DO 203 J=1,WR
C
		IF(TITLE(K) .EQ. WRITE(J))GO TO 202
203		CONTINUE
C	
		WR=WR+1
		WRITE(2,9)TITLE(K),THE_REST
		WRITE(WR)=TITLE(K)
C
202		CONTINUE
201		CONTINUE
200		CONTINUE
C
	ELSE IF(TYPE .EQ. 'G')THEN
C
		DO 208 K=IMS,IME
C
		OPEN(UNIT=2,FILE='EQUGEN.'//MON(K),CARRIAGECONTROL='LIST',
	1	STATUS='UNKNOWN')
C
		IF(MON(K) .EQ. 'JAN')WRITE(2,8)'JANUARY 1'
		IF(MON(K) .EQ. 'FEB')WRITE(2,8)'FEBRUARY 1'
		IF(MON(K) .EQ. 'MAR')WRITE(2,8)'MARCH 1'
		IF(MON(K) .EQ. 'APR')WRITE(2,8)'APRIL 1'
		IF(MON(K) .EQ. 'MAY')WRITE(2,8)'MAY 1'
		IF(MON(K) .EQ. 'JUN')WRITE(2,8)'JUNE 1'
		IF(MON(K) .EQ. 'JUL')WRITE(2,8)'JULY 1'
		WRITE(2,16)TITLE(1),THE_REST,CBTS
16		FORMAT(2A,2X,A)
C
208		CONTINUE
C
C
		OPEN(UNIT=3,CARRIAGECONTROL='LIST',STATUS='UNKNOWN')
C
C
		WRITE(3,17)
17		FORMAT('$!',/,
	1	'$COPY DUA12:[FORECAST.GEN]DUMMY.OUT DUA12:',
	1	'[FORECAST.GEN]FORECAST.OUT',/,
	1	'$PURGE DUA12:[FORECAST.GEN]FORECAST.OUT',/,
	1	'$DELETE DUA12:[FORECAST.GEN]MPOLLUP.ERR;*')
C
C
C
		DO 209 IY=ISY,IEY
C
		IYEAR=IY-1900
C
		DO 210 K=IMS,IME
C
		WRITE(3,14)MON(K),IYEAR
C		WRITE(3,8)'$PURGE'
14		FORMAT('$@DUA12:[FORECAST.GEN]FORECAST EQUGEN ',A,1X,I2)
C
210		CONTINUE
209		CONTINUE
C
		WRITE(3,8)'$SET NOVERIFY'
	END IF		
C
	STOP
	END
